Skip to content

Add inner product and cosine similarity optimizations#7364

Merged
connortsui20 merged 3 commits intodevelopfrom
ct/math-opt
Apr 9, 2026
Merged

Add inner product and cosine similarity optimizations#7364
connortsui20 merged 3 commits intodevelopfrom
ct/math-opt

Conversation

@connortsui20
Copy link
Copy Markdown
Contributor

Summary

Adds compute optimizations for the InnerProduct and CosineSimilarity changes, mostly related to when a child has already been decomposed into normalized and norms via L2Denorm scalar fn array.

Testing

Adds some more tests.

@connortsui20 connortsui20 requested a review from gatesn April 9, 2026 14:24
@connortsui20 connortsui20 added the changelog/performance A performance improvement label Apr 9, 2026
Comment on lines +229 to +234
if !matches!(validity, Validity::NonNullable) {
// Masking always changes the nullability to nullable.
dot.mask(validity.to_array(len))
} else {
Ok(dot)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of awful

@connortsui20 connortsui20 enabled auto-merge (squash) April 9, 2026 15:40
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 9, 2026

Merging this PR will improve performance by 29.94%

⚡ 2 improved benchmarks
✅ 1120 untouched benchmarks
⏩ 1530 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation take_10k_random 251.2 µs 193.3 µs +29.94%
Simulation take_10k_contiguous 315 µs 257 µs +22.57%

Comparing ct/math-opt (79cb061) with develop (0b2a35e)2

Open in CodSpeed

Footnotes

  1. 1530 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on develop (ccc6590) during the generation of this report, so 0b2a35e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@connortsui20 connortsui20 merged commit 47f97f4 into develop Apr 9, 2026
58 checks passed
@connortsui20 connortsui20 deleted the ct/math-opt branch April 9, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants